package com.isoft.c2team3service2.controller;


import com.isoft.c2team3service2.bean.ResponseData;
import org.springframework.stereotype.Component;

@Component
public class BaseController {
    public ResponseData<Boolean> resultBoolean(boolean result, String opr){
        ResponseData<Boolean> responseData=new ResponseData<>();
        if (result) {
            responseData.setErrorCode(200);
            responseData.setMsg(opr +"成功");
        }else {
            responseData.setErrorCode(500);
            responseData.setMsg(opr +"失败");
        }
        responseData.setData(result);
        return responseData;
    }
    public <T> ResponseData<T> resultT(T result,String opr){
        ResponseData<T> responseData=new ResponseData<>();
        if(result!=null){
            responseData.setErrorCode(200);
            responseData.setMsg(opr +"成功");
        }else {
            responseData.setErrorCode(500);
            responseData.setMsg(opr +"失败");
        }
        responseData.setData(result);
        return responseData;
    }
    public <T> ResponseData<T> resultT2(T result,String opr){
        ResponseData<T> responseData=new ResponseData<>();
        if(result != null){
            responseData.setErrorCode(200);
            responseData.setMsg(opr +"登录成功");
        }else {
            responseData.setErrorCode(500);
            responseData.setMsg(opr +"登录失败");
        }
        responseData.setData(result);
        return responseData;
    }
}
